﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using AjaxPro;
using System.Text;
using Mang24k99.Model.KEYW;
using Mang24k99.Business.KEYW;

namespace Mang24k99.Web.KEYW
{

    public partial class KtKeyWords : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.btnSave1.Attributes.Add("onclick", "return Validate('" + this.txtWordsNo1.ClientID + "','" + this.txtWordsName1.ClientID + "')");
            this.btnSave2.Attributes.Add("onclick", "return Validate('" + this.txtWordsNo2.ClientID + "','" + this.txtWordsName2.ClientID + "')");
            this.btnCancel1.Attributes.Add("onclick", "return Cancel()");
            this.btnCancel2.Attributes.Add("onclick", "return Cancel()");
            //注册Ajax方法
            AjaxPro.Utility.RegisterTypeForAjax(typeof(KtKeyWords));
            if (!IsPostBack)
            {
                LoadKeyWord1();
                LoadKeyWord2();
            }

        }

        /// <summary>
        /// 通过输入值查找匹配的关键字
        /// </summary>
        /// <param name="Spell"></param>
        /// <param name="objtxt"></param>
        /// <param name="objtxtSource"></param>
        /// <returns></returns>
        [AjaxMethod]
        public string GetSearchStockResult(string Spell, string objtxt, string objtxtSource)
        {
            StringBuilder stringBuilderReturn = new StringBuilder();

            stringBuilderReturn.Append("<table id=\"searchTable\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" align=\"center\"  bordercolor=\"#BED6A6\"");
            stringBuilderReturn.Append("style=\"border-collapse: collapse\">");
            try
            {
                MKtKeywNewstraword[] starword = (MKtKeywNewstraword[])BKeyWords.SelectByInput(Spell);
                for (int i = 0; i < starword.Length; i++)
                {
                    stringBuilderReturn.Append("<tr>");
                    stringBuilderReturn.Append("<td class=\"tb_txt2\"  nowrap=\"nowrap\" style=\"cursor:pointer;\" title=\"" + starword[i].WordNO + "\" onclick=\"SearchStockHide('" + objtxt + "',this.innerHTML,'" + objtxtSource + "',this.title)\">");
                    stringBuilderReturn.Append("" + starword[i].WordName + "</td>");
                    stringBuilderReturn.Append("</tr>");
                }
            }
            catch (System.Exception e)
            {

            }
            stringBuilderReturn.Append("</table>");
            return stringBuilderReturn.ToString();
        }
        /// <summary>
        /// 保存关键字词组1
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave1_Click(object sender, EventArgs e)
        {
            TextBox[] txtboxlist = GetTextBoxList1();
            TextBox[] txtboxhlist = GetTextBoxHList1();
            //当清空首页显示关键字词组时代表删除该词组
            if (this.txtWordsNo1.Text != "" && this.txtWordsName1.Text.Trim() == "")
            {
                MKtKeywFixwords fixword = new MKtKeywFixwords();
                int wordsno = Int32.Parse(this.txtWordsNo1.Text);
                MKtKeywWords keyword = MKtKeywWords.SelectByPrimaryKey(wordsno);

                try
                {
                    MKtKeywWords.Delete(keyword);
                    ClearKeyWord1();
                    LoadKeyWord1();
                    return;
                }
                catch (System.Exception exc)
                {

                }
            }
            if (txtWordsName1.Text.Trim()==txtWordsName2.Text.Trim())
            {
                string strMsg = "首页显示关键词组1与关键词组2名称不能重复!";
                Common.MessageBox.Show(this.Page, strMsg);
                return;
            }
              //主关键字为空
            if (this.txtMainWrod1.Text.Trim() == "" || this.txtMainWrod1H.Text.Trim() == "")
            {
                string strMsg = "主关键字不能为空!";
                Common.MessageBox.Show(this.Page, strMsg);
                return;
            }
            else
            {
                int count = 0;
                for (count = 0; count < 8; count++)
                {
                    //如果有一个副关键字被选上则跳出
                    if (txtboxhlist[count].Text.Trim() != "" && txtboxlist[count].Text.Trim() != "")
                    {
                        break;
                    }
                }
                if (count == 8)
                {
                    string strMsg = "请至少选择一个副关键字!";
                    Common.MessageBox.Show(this.Page, strMsg);
                    return;
                }
            }
            if (IsRepeat1() == false)
            {
                string strMsg = "关键字不能重复!";
                Common.MessageBox.Show(this.Page, strMsg);
                return;
            }
            //新增关键字词组一
            if (this.txtWordsNo1.Text=="" &&this.txtWordsName1.Text.Trim()!="")
            {  
                Session["Action"] = "Insert";
                SaveMainWord1();
                SaveFixWord1();
                string strMsg = "新增成功!";
                Common.MessageBox.Show(this.Page, strMsg);
                ClearKeyWord1();
                LoadKeyWord1();
            }
            //修改关键词词组
            if (this.txtWordsNo1.Text != "" && this.txtWordsName1.Text.Trim() != "")
            {
                Session["Action"] = "Update";
                SaveMainWord1();
                SaveFixWord1();
                string strMsg = "修改成功!";
                Common.MessageBox.Show(this.Page, strMsg);
                ClearKeyWord1();
                LoadKeyWord1();
            }

        }
        /// <summary>
        /// 加载关键词组一
        /// </summary>
        public void LoadKeyWord1()
        {
            try
            {
                MKtKeywWords[] keyword = (MKtKeywWords[])MKtKeywWords.SelectAll();
                //遍历关键字词组表
                for (int i = 0; i < keyword.Length; i++)
                {
                    //关键字词组一
                    if (keyword[i].WordsNO == 1)
                    {
                        this.txtWordsName1.Text = keyword[i].WordsName;
                        this.txtWordsNo1.Text = keyword[i].WordsNO.ToString();
                        this.txtMainWrod1.Text = keyword[i].MKtKeywNewstraword.WordName;
                        this.txtMainWrod1H.Text = keyword[i].MKtKeywNewstraword.WordNO.ToString();
                        IsValidate(keyword[i].MKtKeywNewstraword.WordNO,txtMainWrod1);
                        TextBox[] txtboxlist1 = GetTextBoxList1();
                        TextBox[] txtboxhlist1 = GetTextBoxHList1();
                        //遍历关键词组一对应关键字
                        for (int j = 0; j < keyword[i].MKtKeywFixwords.Count; j++)
                        {
                            MKtKeywFixwords fixword = keyword[i].MKtKeywFixwords[j];
                            //遍历页面关键字显示textbox，分别给对应的textbox赋值
                            for (int list = 0; list < 8; list++)
                            {
                                if (fixword.ORDER == list + 1)
                                {
                                    txtboxlist1[list].Text = fixword.MKtKeywNewstraword.WordName;
                                    txtboxhlist1[list].Text = fixword.MKtKeywNewstraword.WordNO.ToString();
                                    IsValidate(fixword.MKtKeywNewstraword.WordNO, txtboxlist1[list]);
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception e)
            {

            }

        }
        /// <summary>
        /// 加载关键词组二
        /// </summary>
        public void LoadKeyWord2()
        {
            try
            {
                MKtKeywWords[] keyword = (MKtKeywWords[])MKtKeywWords.SelectAll();
                //遍历关键字词组表
                for (int i = 0; i < keyword.Length; i++)
                {
                    //关键字词组二
                    if (keyword[i].WordsNO == 2)
                    {
                        this.txtWordsName2.Text = keyword[i].WordsName;
                        this.txtWordsNo2.Text = keyword[i].WordsNO.ToString();
                        this.txtMainWrod2.Text = keyword[i].MKtKeywNewstraword.WordName;
                        this.txtMainWrod2H.Text = keyword[i].MKtKeywNewstraword.WordNO.ToString();
                        IsValidate(keyword[i].MKtKeywNewstraword.WordNO,txtMainWrod2);
                        TextBox[] txtboxlist2 = GetTextBoxList2();
                        TextBox[] txtboxhlist2 = GetTextBoxHList2();

                        //遍历关键词组一对应关键字
                        for (int j = 0; j < keyword[i].MKtKeywFixwords.Count; j++)
                        {
                            MKtKeywFixwords fixword = keyword[i].MKtKeywFixwords[j];
                            //遍历页面关键字显示textbox，分别给对应的textbox赋值
                            for (int list = 0; list < 8; list++)
                            {
                                if (fixword.ORDER == list + 1)
                                {
                                    txtboxlist2[list].Text = fixword.MKtKeywNewstraword.WordName;
                                    txtboxhlist2[list].Text = fixword.MKtKeywNewstraword.WordNO.ToString();
                                    IsValidate(fixword.MKtKeywNewstraword.WordNO, txtboxlist2[list]);
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception e)
            {

            }
        }
        /// <summary>
        /// 保存关键字词组2
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave2_Click(object sender, EventArgs e)
        {
            TextBox[] txtboxlist = GetTextBoxList2();
            TextBox[] txtboxhlist = GetTextBoxHList2();
            //当清空首页显示关键字词组时代表删除该词组
            if (this.txtWordsNo2.Text != "" && this.txtWordsName2.Text.Trim() == "")
            {
                MKtKeywFixwords fixword = new MKtKeywFixwords();
                int wordsno = Int32.Parse(this.txtWordsNo2.Text);
                MKtKeywWords keyword = MKtKeywWords.SelectByPrimaryKey(wordsno);

                try
                {
                    MKtKeywWords.Delete(keyword);
                    ClearKeyWord2();
                    LoadKeyWord2();
                    return;
                }
                catch (System.Exception ex)
                {

                }
            }
            if (txtWordsName1.Text.Trim() == txtWordsName2.Text.Trim())
            {
                string strMsg = "首页显示关键词组1与关键词组2名称不能重复!";
                Common.MessageBox.Show(this.Page, strMsg);
                return;
            }
            //主关键字为空
            if (this.txtMainWrod2.Text.Trim() == "" || this.txtMainWrod2H.Text.Trim() == "")
            {
                string strMsg = "主关键字不能为空!";
                Common.MessageBox.Show(this.Page, strMsg);
                return;
            }
            else
            {
                int count = 0;
                for (count = 0; count < 8; count++)
                {
                    //如果有一个副关键字被选上则跳出
                    if (txtboxhlist[count].Text.Trim() != "" && txtboxlist[count].Text.Trim() != "")
                    {
                        break;
                    }
                }
                if (count == 8)
                {
                    string strMsg = "请至少选择一个副关键字！";
                    Common.MessageBox.Show(this.Page, strMsg);
                    return;
                }
            }
            if (IsRepeat2() == false)
            {
                string strMsg = "关键字不能重复!";
                Common.MessageBox.Show(this.Page, strMsg);
                return;
            }
            //新增关键字词组2
            if (this.txtWordsNo2.Text == "" && this.txtWordsName2.Text.Trim() != "")
            {
                Session["Action"] = "Insert";
                SaveMainWord2();
                SaveFixWord2();
                string strMsg = "新增成功!";
                Common.MessageBox.Show(this.Page, strMsg);
                ClearKeyWord2();
                LoadKeyWord2();
            }
            //修改关键词词组2
            if (this.txtWordsNo2.Text != "" && this.txtWordsName2.Text.Trim() != "")
            {
                Session["Action"] = "Update";
                SaveMainWord2();
                SaveFixWord2();
                string strMsg = "修改成功!";
                Common.MessageBox.Show(this.Page, strMsg);
                ClearKeyWord2();
                LoadKeyWord2();
            }   
        }

        /// <summary>
        /// 获取词组一显示关键词名称TextBox
        /// </summary>
        /// <returns></returns>
        public TextBox[] GetTextBoxList1()
        {
            TextBox[] txtboxlist = new TextBox[8];
            txtboxlist[0] = txtFixWordNo11;
            txtboxlist[1] = txtFixWordNo12;
            txtboxlist[2] = txtFixWordNo13;
            txtboxlist[3] = txtFixWordNo14;
            txtboxlist[4] = txtFixWordNo15;
            txtboxlist[5] = txtFixWordNo16;
            txtboxlist[6] = txtFixWordNo17;
            txtboxlist[7] = txtFixWordNo18;

            return txtboxlist;
        }

        /// <summary>
        /// 获取词组一显示关键词编号TextBox
        /// </summary>
        /// <returns></returns>
        public TextBox[] GetTextBoxHList1()
        {
            TextBox[] txtboxhlist = new TextBox[8];
            txtboxhlist[0] = txtFixWordNo11H;
            txtboxhlist[1] = txtFixWordNo12H;
            txtboxhlist[2] = txtFixWordNo13H;
            txtboxhlist[3] = txtFixWordNo14H;
            txtboxhlist[4] = txtFixWordNo15H;
            txtboxhlist[5] = txtFixWordNo16H;
            txtboxhlist[6] = txtFixWordNo17H;
            txtboxhlist[7] = txtFixWordNo18H;

            return txtboxhlist;
        }

        /// <summary>
        /// 获取词组二显示关键词名称TextBox
        /// </summary>
        /// <returns></returns>
        public TextBox[] GetTextBoxList2()
        {
            TextBox[] txtboxlist = new TextBox[8];
            txtboxlist[0] = txtFixWordNo21;
            txtboxlist[1] = txtFixWordNo22;
            txtboxlist[2] = txtFixWordNo23;
            txtboxlist[3] = txtFixWordNo24;
            txtboxlist[4] = txtFixWordNo25;
            txtboxlist[5] = txtFixWordNo26;
            txtboxlist[6] = txtFixWordNo27;
            txtboxlist[7] = txtFixWordNo28;

            return txtboxlist;
        }
        /// <summary>
        /// 获取词组二显示关键词编号TextBox
        /// </summary>
        /// <returns></returns>
        public TextBox[] GetTextBoxHList2()
        {
            TextBox[] txtboxhlist = new TextBox[8];
            txtboxhlist[0] = txtFixWordNo21H;
            txtboxhlist[1] = txtFixWordNo22H;
            txtboxhlist[2] = txtFixWordNo23H;
            txtboxhlist[3] = txtFixWordNo24H;
            txtboxhlist[4] = txtFixWordNo25H;
            txtboxhlist[5] = txtFixWordNo26H;
            txtboxhlist[6] = txtFixWordNo27H;
            txtboxhlist[7] = txtFixWordNo28H;

            return txtboxhlist;
        }

        protected void btnCancel1_Click(object sender, EventArgs e)
        {
			ClearKeyWord1();
			LoadKeyWord1();
			//ClearPage();
        }

        protected void btnCancel2_Click(object sender, EventArgs e)
        {
            ClearKeyWord2();
            LoadKeyWord2();
        }
        //清空页面
        public void ClearPage()
        {
            int nPageControls = this.Page.Form.Controls.Count;
            for (int i = 0; i < nPageControls; i++)
            {
                foreach (System.Web.UI.Control control in this.Page.Form.Controls[i].Controls)
                {
                    if (control is TextBox)
                    {
                        (control as TextBox).Text =string.Empty;
                    }
                }
            }
        }
        /// <summary>
        /// 清空关键词组一
        /// </summary>
        public void ClearKeyWord1()
        {
            this.txtMainWrod1.Text = "";
            this.txtWordsName1.Text = "";
            this.txtMainWrod1H.Text = "";
            this.txtWordsNo1.Text = "";
            this.txtMainWrod1.BackColor = System.Drawing.Color.White;
            TextBox[] txtboxlist = GetTextBoxList1();
            TextBox[] txtboxhlist = GetTextBoxHList1();
            for (int i = 0; i < txtboxlist.Length;i++ )
            {
                txtboxlist[i].Text = "";
                txtboxlist[i].BackColor = System.Drawing.Color.White;
            }
            for (int i = 0; i < txtboxhlist.Length;i++ )
            {
                txtboxhlist[i].Text = "";
            }
        }
        /// <summary>
        /// 清空关键词组二
        /// </summary>
        public void ClearKeyWord2()
        {
            this.txtWordsNo2.Text = "";
            this.txtWordsName2.Text = "";
            this.txtMainWrod2H.Text = "";
            this.txtMainWrod2.Text = "";
            this.txtMainWrod2.BackColor = System.Drawing.Color.White;
            TextBox[] txtboxlist = GetTextBoxList2();
            TextBox[] txtboxhlist = GetTextBoxHList2();
            for (int i = 0; i < txtboxlist.Length; i++)
            {
                txtboxlist[i].Text = "";
                txtboxlist[i].BackColor = System.Drawing.Color.White;
            }
            for (int i = 0; i < txtboxhlist.Length; i++)
            {
                txtboxhlist[i].Text = "";
            }
        }
        //保存词组一主关键词
        public void SaveMainWord1()
        {
            MKtKeywNewstraword newstraword = new MKtKeywNewstraword();
            newstraword.WordNO = Int32.Parse(this.txtMainWrod1H.Text.Trim());
            MKtKeywWords kewwords = new MKtKeywWords();
            if (Session["Action"].ToString() == "Update")
            {
               kewwords = MKtKeywWords.SelectByPrimaryKey(1);
            }         
            kewwords.MKtKeywNewstraword = newstraword;
            kewwords.WordsNO = 1;
            kewwords.WordsName = this.txtWordsName1.Text.Trim();
            kewwords.IsValidate = 1;
            if (Session["Action"].ToString()=="Insert")
            {
                kewwords.InputTime = DateTime.Now;
                try
                {
                    BKeyWords.Create(kewwords);
                }
                catch (System.Exception ex)
                {

                }
            }

            if (Session["Action"].ToString()=="Update")
            {
                kewwords.ModifyTime = DateTime.Now;
                try
                {
                    MKtKeywWords.Update(kewwords);
                }
                catch (System.Exception e)
                {
                	
                }
            }
        }

        //保存关键字附表数据
        public void SaveFixWord1()
        {
            ArrayList fixwordList = new ArrayList();
            TextBox[] txtboxlist = GetTextBoxList1();
            TextBox[] txtboxhlist = GetTextBoxHList1();

            for (int i = 0; i < 8; i++)
            {
                //清空附关键字textbox，代表删除该附关键字
                if (txtboxlist[i].Text.Trim() == "" && txtboxhlist[i].Text.Trim() != "")
                {
                    MKtKeywFixwords[] fixwordlist = (MKtKeywFixwords[])MKtKeywFixwords.SelectByOrder(i+1,1);
                    if (fixwordlist.Length != 0)
                    {
                        MKtKeywFixwords.Delete(fixwordlist[0]);
                    }
                }
                if (txtboxlist[i].Text.Trim() != "" && txtboxhlist[i].Text.Trim() != "")
                {
                    MKtKeywFixwords[] fixwordlist = (MKtKeywFixwords[])MKtKeywFixwords.SelectByOrder(i+1,1);
                    if (fixwordlist.Length != 0)
                    {
                        MKtKeywFixwords.Delete(fixwordlist[0]);
                    }
                    MKtKeywFixwords fixword = new MKtKeywFixwords();
                    MKtKeywNewstraword straword = new MKtKeywNewstraword();
                    straword.WordNO = Int32.Parse(txtboxhlist[i].Text.Trim());
                    MKtKeywWords keyword = MKtKeywWords.SelectByPrimaryKey(1);
                    MKtKeywNewstraword mainword = new MKtKeywNewstraword();
                    mainword = keyword.MKtKeywNewstraword;
                    fixword.MKtKeywNewstraword = straword;
                    fixword.MKtKeywWords = keyword;
                    fixword.IsValidate = 1;
                    fixword.InputTime = DateTime.Now;
                    fixword.ORDER = i + 1;
                    fixword.CompositeNO = mainword.WordNO + "," + straword.WordNO;
                    fixwordList.Add(fixword);
                    try
                    {
                        BKeyWords.CreateFix(fixword);
                    }
                    catch (System.Exception e)
                    {     	
                    }
                }
            }
        }

        //保存词组2主关键词
        public void SaveMainWord2()
        {
            MKtKeywNewstraword newstraword = new MKtKeywNewstraword();
            newstraword.WordNO = Int32.Parse(this.txtMainWrod2H.Text.Trim());
            MKtKeywWords kewwords = new MKtKeywWords();
            if (Session["Action"].ToString() == "Update")
            {
                kewwords = MKtKeywWords.SelectByPrimaryKey(2);
            }
            kewwords.MKtKeywNewstraword = newstraword;
            kewwords.WordsNO = 2;
            kewwords.WordsName = this.txtWordsName2.Text.Trim();
            kewwords.IsValidate = 1;
            if (Session["Action"].ToString() == "Insert")
            {
                kewwords.InputTime = DateTime.Now;
                try
                {
                    BKeyWords.Create(kewwords);
                }
                catch (System.Exception ex)
                {
                    throw;
                }
            }

            if (Session["Action"].ToString() == "Update")
            {
                kewwords.ModifyTime = DateTime.Now;
                try
                {
                    MKtKeywWords.Update(kewwords);
                }
                catch (System.Exception e)
                {

                }
            }


        }

        //保存关键字词组2附表数据
        public void SaveFixWord2()
        {
            ArrayList fixwordList = new ArrayList();
            TextBox[] txtboxlist = GetTextBoxList2();
            TextBox[] txtboxhlist = GetTextBoxHList2();

            for (int i = 0; i < 8; i++)
            {
                //清空附关键字textbox，代表删除该附关键字
                if (txtboxlist[i].Text.Trim() == "" && txtboxhlist[i].Text.Trim() != "")
                {
                    MKtKeywFixwords[] fixwordlist = (MKtKeywFixwords[])MKtKeywFixwords.SelectByOrder(i + 1,2);
                    if (fixwordlist.Length != 0)
                    {
                        MKtKeywFixwords.Delete(fixwordlist[0]);
                    }
                }
                if (txtboxlist[i].Text.Trim() != "" && txtboxhlist[i].Text.Trim() != "")
                {
                    MKtKeywFixwords[] fixwordlist = (MKtKeywFixwords[])MKtKeywFixwords.SelectByOrder(i + 1,2);
                    if (fixwordlist.Length != 0)
                    {
                        MKtKeywFixwords.Delete(fixwordlist[0]);
                    }
                    MKtKeywFixwords fixword = new MKtKeywFixwords();
                    MKtKeywNewstraword straword = new MKtKeywNewstraword();
                    straword.WordNO = Int32.Parse(txtboxhlist[i].Text.Trim());
                    MKtKeywWords keyword = MKtKeywWords.SelectByPrimaryKey(2);
                    MKtKeywNewstraword mainword = new MKtKeywNewstraword();
                    mainword = keyword.MKtKeywNewstraword;
                    fixword.MKtKeywNewstraword = straword;
                    fixword.MKtKeywWords = keyword;
                    fixword.IsValidate = 1;
                    fixword.InputTime = DateTime.Now;
                    fixword.ORDER = i + 1;
                    fixword.CompositeNO = mainword.WordNO + "," + straword.WordNO;
                    fixwordList.Add(fixword);
                    try
                    {
                        BKeyWords.CreateFix(fixword);
                    }
                    catch (System.Exception e)
                    {
                        throw;
                    }

                }
            }
        }
        //检测关键字词组一是否有重复
        public Boolean IsRepeat1()
        {
            TextBox[] txtboxhlist1 = GetTextBoxHList1();
            TextBox[] txtboxlist1 = GetTextBoxList1();
            for (int i = 0; i < txtboxhlist1.Length;i++ )
            {
                if (txtboxhlist1[i].Text==txtMainWrod1H.Text&&txtboxhlist1[i].Text.Trim()!="" && txtboxlist1[i].Text.Trim()!="")
                {
                    return false;
                }
            }
            for (int i = 0; i < txtboxhlist1.Length-1;i++ )
            {
                for (int j = i + 1; j < txtboxhlist1.Length;j++ )
                {
                    if (txtboxlist1[i].Text.Trim() != ""&&txtboxlist1[j].Text.Trim()!="")
                    {
                        if (txtboxhlist1[i].Text == txtboxhlist1[j].Text && txtboxhlist1[i].Text.Trim() != "")
                        {
                            return false;
                        }
                    }                
                }
            }
            return true;
        }

        //检测关键字词组二是否有重复
        public Boolean IsRepeat2()
        {
            TextBox[] txtboxhlist2 = GetTextBoxHList2();
            TextBox[] txtboxlist2 = GetTextBoxList2();
            for (int i = 0; i < txtboxhlist2.Length; i++)
            {
                if (txtboxhlist2[i].Text == txtMainWrod2H.Text && txtboxhlist2[i].Text!="" && txtboxlist2[i].Text.Trim()!="")
                {
                    return false;
                }
            }
            for (int i = 0; i < txtboxhlist2.Length - 1; i++)
            {
                for (int j = i + 1; j < txtboxhlist2.Length; j++)
                {
                    if (txtboxlist2[i].Text.Trim() != "" && txtboxhlist2[j].Text.Trim()!="")
                    {
                        if (txtboxhlist2[i].Text == txtboxhlist2[j].Text && txtboxhlist2[i].Text != "")
                        {
                            return false;
                        }
                    }
                }
            }
            return true;
        }

        /// <summary>
        /// 验证关键字是否失效，失效则改版文本框底色
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="txtbox"></param>
        public void IsValidate(int keyword,TextBox  txtbox)
        {
            if (BKeyWords.IsValidate(keyword)==false)
            {
                txtbox.BackColor = System.Drawing.Color.FromArgb(249,134,157);
            }
        }
    }
}